'use client';

import { usePathname } from 'next/navigation';
import Header from '@/components/Header';
import Footer from '@/components/Footer'


export default function ClientLayoutWrapper({
  children,
}: {
  children: React.ReactNode;
}) {
  const pathname = usePathname();
  
  // 判断是否为需要隐藏 Header 和 Footer 的页面
  // 1. 题词页面 (可能在 /read 路径下)
  // 2. 课程页面 (/course/[token])
  // 3. 学习页面 (/course/[token]/learn)
  // 4. PPT 展示页面 (/pptedit/show)
  if (
    pathname?.includes('/read') || 
    pathname?.includes('/pptedit/show') ||
    pathname?.includes('/user') ||
    (pathname?.includes('/course') && !pathname?.includes('/courses'))
  ) {
    return (
      <>
        <main className="flex-grow">
          {children}
        </main>
      </>
    );
  }
  
  // 音乐页面保留 Header
  if (pathname?.includes('/music')) {
    return (
      <>
      <Header />
        <main className="flex-grow">
          {children}
        </main>
      </>
    );
  }  

  // 其他页面显示 Header 和 Footer
  return  (
    <>
        <Header />
        <main className="flex-grow">
            {children}
        </main>
        <Footer />
    </>
  );
}